package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BieBlacklist;
import com.ruoyi.system.service.IBieBlacklistService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 黑名单记录Controller
 * 
 * @author zxl
 * @date 2021-05-03
 */
@RestController
@RequestMapping("/system/blacklist_records")
public class BieBlacklistController extends BaseController
{
    @Autowired
    private IBieBlacklistService bieBlacklistService;

    /**
     * 查询黑名单记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:blacklist_records:list')")
    @GetMapping("/list")
    public TableDataInfo list(BieBlacklist bieBlacklist)
    {
        startPage();
        List<BieBlacklist> list = bieBlacklistService.selectBieBlacklistList(bieBlacklist);
        return getDataTable(list);
    }

    /**
     * 导出黑名单记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:blacklist_records:export')")
    @Log(title = "黑名单记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BieBlacklist bieBlacklist)
    {
        List<BieBlacklist> list = bieBlacklistService.selectBieBlacklistList(bieBlacklist);
        ExcelUtil<BieBlacklist> util = new ExcelUtil<BieBlacklist>(BieBlacklist.class);
        return util.exportExcel(list, "黑名单记录数据");
    }

    /**
     * 获取黑名单记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:blacklist_records:query')")
    @GetMapping(value = "/{blacklistId}")
    public AjaxResult getInfo(@PathVariable("blacklistId") String blacklistId)
    {
        return AjaxResult.success(bieBlacklistService.selectBieBlacklistById(blacklistId));
    }

    /**
     * 新增黑名单记录
     */
    @PreAuthorize("@ss.hasPermi('system:blacklist_records:add')")
    @Log(title = "黑名单记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BieBlacklist bieBlacklist)
    {
        return toAjax(bieBlacklistService.insertBieBlacklist(bieBlacklist));
    }

    /**
     * 修改黑名单记录
     */
    @PreAuthorize("@ss.hasPermi('system:blacklist_records:edit')")
    @Log(title = "黑名单记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BieBlacklist bieBlacklist)
    {
        return toAjax(bieBlacklistService.updateBieBlacklist(bieBlacklist));
    }

    /**
     * 删除黑名单记录
     */
    @PreAuthorize("@ss.hasPermi('system:blacklist_records:remove')")
    @Log(title = "黑名单记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{blacklistIds}")
    public AjaxResult remove(@PathVariable String[] blacklistIds)
    {
        return toAjax(bieBlacklistService.deleteBieBlacklistByIds(blacklistIds));
    }
}
